from k_mean import k_mean


if __name__ == '__main__':
    sample_file = open('ClusterSamples.csv', 'r')
    samples = sample_file.readlines()
    sample_file.close()
    label_file = open('SampleLabels.csv', 'r')
    labels = label_file.readlines()
    label_file.close()

    samples = [line.strip().split(',') for line in samples]
    dim = len(samples[0])
    for sample in samples:
        for i in range(dim):
            sample[i] = int(sample[i])
    labels = [int(line.strip()) for line in labels]

    k = 10
    threshold = 0.01
    centers, sample_to_class, iter_count = k_mean(samples, k, threshold)

    for i in range(k):
        count = [0] * k
        for j in range(len(labels)):
            if labels[j] == i:
                pred = sample_to_class[j]
                count[pred] += 1
        print(i)
        print(count)
